package com.qd.common.panda.domain.entity.info;

import com.cdqidi.util.page.BaseQuery;
import com.cdqidi.valid.group.DefaultGroup;
import com.cdqidi.valid.group.DeleteGroup;
import com.cdqidi.valid.group.UpdateGroup;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;

/**
 * 车位信息
 *
 * @author sjk
 */
@EqualsAndHashCode(callSuper = true)
@Getter
@Setter
public class ParkInfoDTO extends BaseQuery {

    /**
     * 主键
     */
    @NotBlank(message = "车位ID不能为空", groups = {DeleteGroup.class, UpdateGroup.class})
    @Size(max = 50, message = "车位ID长度不能超过{max}位", groups = {DeleteGroup.class, UpdateGroup.class})
    private String aid;
    /**
     * 所在地区编码
     */
    private String region;
    /**
     * 所在地区名称
     */
    private String regionName;
    /**
     * 停车场位置
     */
    @Size(max = 200, message = "停车场位置长度不能超过{max}位", groups = DefaultGroup.class)
    private String address;
    /**
     * 车位号
     */
    @Size(max = 20, message = "车位号长度不能超过{max}位", groups = DefaultGroup.class)
    private String spaceNumber;
    /**
     * 熊猫泊车车位号
     */
    private String sysSpaceNumber;
    /**
     * 说明
     */
    @Size(max = 200, message = "说明长度不能超过{max}位", groups = DefaultGroup.class)
    private String note;
    /**
     * 提交时间
     */
    private LocalDateTime addTime;
    /**
     * 修改时间
     */
    private LocalDateTime updateTime;
    /**
     * 审核状态:0未审核1审核通过2审核未通过
     */
    private Integer approvalStatus;
    /**
     * 审核结果:不通过需要填写原因
     */
    @Size(max = 200, message = "审核结果长度不能超过{max}位", groups = DefaultGroup.class)
    private String approvalResult;
    /**
     * 审核时间
     */
    private LocalDateTime approvalTime;
    /**
     * 审核人单位
     */
    @Size(max = 50, message = "审核人单位长度不能超过{max}位", groups = DefaultGroup.class)
    private String approvalUnit;
    /**
     * 审核人单位显示
     */
    private String approvalUnitDisplay;
    /**
     * 申请人
     */
    @Size(max = 50, message = "申请人长度不能超过{max}位", groups = DefaultGroup.class)
    private String applicant;
    /**
     * 申请人手机号
     */
    private String mobile;
    /**
     * 停车场标识
     */
    @NotBlank(message = "停车场标识不能为空", groups = DefaultGroup.class)
    @Size(max = 50, message = "停车场标识长度不能超过{max}位", groups = DefaultGroup.class)
    private String parkId;
    /**
     * 停车产名称
     */
    private String parkIdDisplay;
    /**
     * 车位大小
     */
    @NotBlank(message = "车位大小不能为空", groups = DefaultGroup.class)
    @Size(max = 50, message = "车位大小长度不能超过{max}位", groups = DefaultGroup.class)
    private String parkSpaceSize;
    /**
     * 车位大小显示
     */
    private String parkSpaceSizeDisplay;
    /**
     * 车位类型
     */
    @NotBlank(message = "车位类型不能为空", groups = DefaultGroup.class)
    @Size(max = 50, message = "车位类型长度不能超过{max}位", groups = DefaultGroup.class)
    private String parkSpaceType;
    /**
     * 车位类型显示
     */
    private String parkSpaceTypeDisplay;
    /**
     * 审核人
     */
    @Size(max = 50, message = "审核人长度不能超过{max}位", groups = DefaultGroup.class)
    private String approvalUser;
    /**
     * 车位平面图
     */
    @Size(max = 200, message = "车位平面图长度不能超过{max}位", groups = DefaultGroup.class)
    private String planPic;
    /**
     * 审核人显示
     */
    private String approvalUserDisplay;
    /**
     * 车位照片
     */
    @Valid
    private List<ParkInfoPicDTO> picList;
    /**
     * 车位产权
     */
    @Valid
    private List<ParkInfoPropertyRightDTO> propertyRightList;

    @Override
    public void freeData() {
        this.aid = null;
        this.address = null;
        this.region = null;
        this.regionName = null;
        this.spaceNumber = null;
        this.note = null;
        this.addTime = null;
        this.updateTime = null;
        this.approvalStatus = null;
        this.approvalResult = null;
        this.approvalTime = null;
        this.approvalUnit = null;
        this.approvalUnitDisplay = null;
        this.applicant = null;
        this.mobile = null;
        this.parkId = null;
        this.parkIdDisplay = null;
        this.parkSpaceSize = null;
        this.parkSpaceSizeDisplay  = null;
        this.parkSpaceType = null;
        this.parkSpaceTypeDisplay = null;
        this.approvalUser = null;
        this.approvalUserDisplay = null;
        this.planPic = null;
        Optional.ofNullable(picList).ifPresent(List::clear);
        Optional.ofNullable(propertyRightList).ifPresent(List::clear);
        super.freeData();
    }
}
